﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Marbles.Data
{
    public class DataSourceTable
    {
        public string Database { get { return this._database; } }
        public string Owner { get { return this._owner; } }
        public string Name { get { return this._name; } }
        public string Comments { get { return this._comments; } }
        public DataSourceTableType TableType { get { return _tabletype; } }

        private DataSourceTableType _tabletype = DataSourceTableType.DataTable;
        private string _database = string.Empty;
        private string _owner = string.Empty;
        private string _name = string.Empty;
        private string _comments = string.Empty;

        public DataSourceTable(string database,string owner, string name, string comments, DataSourceTableType TableType)
        {
            this._database = database;
            this._name = name;
            this._owner = owner;
            this._comments = comments;
            this._tabletype = TableType;
        }

        public DataSourceTable(string database, string owner, string name, DataSourceTableType TableType)
        {
            this._tabletype = TableType;
            this._database = database;
            this._name = name;
            this._owner = owner;
            this._comments = string.Empty;
        }

        public override string ToString()
        {
            if (Owner != string.Empty)
            {
                return string.Format("{0}.{1}", Owner, Name);
            }

            return Name;
        }
    }

    public enum DataSourceTableType
    {
        InternalTable, SystemTable, DataTable, DataView, TableFunction, InlineTableFunction, ClrTableFunction
    }
}
